/**
 * 存储柜
 * @type {[type]}
 */
 const mongoose = require('mongoose')

 const { Schema } = mongoose
 
 
 const CabinetSchema = new Schema({
                                                               
     name: { type: String},   //柜名称
 
     code: { type: String},   //柜编号
 
     volume: {type: Number}, // 柜容量

     specs: {type: String}, // 规格

     enterprise_id: { type: Schema.Types.ObjectId, ref: 'enterprise', required: true}, //  所属企业

     cabinet_status : {type: Number, enum: [1,2,3], default: 1},//柜子状态 1、正常 2、异常、3中止

     status: {type: Number, enum: [1,2,], default: 1},  //状态 1、正常 2、删除
 
     create_at: { type: Date, default: Date.now, index: -1,select: true },
     update_at: { type: Date, default: Date.now ,select: true},
 })
 
 
 CabinetSchema.pre('save', function (next) {
     let now = new Date()
     this.update_at = now
     
     next()
 })
 
 
 
 mongoose.model('cabinet', CabinetSchema)
 module.exports = CabinetSchema
 